﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace OBUCare.Core.Common
{
    /// <summary>
    /// 日志助手类
    /// </summary>
    public static class TraceHelper
    {
        private static readonly log4net.ILog log;

        static TraceHelper()
        {
            log4net.Config.XmlConfigurator.Configure();
            log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        }

        public static log4net.ILog Loger
        {
            get
            {
                return log;
            }
        }
                

        /// <summary>
        /// 写入调试级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        public static void TraceDebug(string Message)
        {
            Loger.Debug(Message);
        }

        /// <summary>
        /// 写入调试级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        /// <param name="args">variable argument list</param>
        public static void TraceDebug(string Message, params object[] args)
        {
            Loger.DebugFormat(Message, args);
        }

        /// <summary>
        /// 写入 Info 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        public static void TraceInfo(string Message)
        {
            Loger.Info(Message);
        }

        /// <summary>
        /// 写入 Info 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        /// <param name="args">variable argument list</param>
        public static void TraceInfo(string Message, params object[] args)
        {
            Loger.InfoFormat(Message, args);
        }

        /// <summary>
        /// 写入 Warn 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        public static void TraceWarning(string Message)
        {
            Loger.Warn(Message);
        }

        /// <summary>
        /// 写入 Warn 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        /// <param name="args">variable argument list</param>
        public static void TraceWarning(string Message, params object[] args)
        {
            Loger.WarnFormat(Message, args);
        }

        /// <summary>
        /// 写入 Warn 级别的日志
        /// </summary>
        public static void TraceWarning(string additionalMessage, Exception ex)
        {
            Loger.Warn(additionalMessage, ex);
        }

        /// <summary>
        /// 写入 Warn 级别的日志
        /// </summary>
        public static void TraceWarning(Exception ex)
        {
            Loger.Warn(string.Empty, ex);
        }

        /// <summary>
        /// 写入 Error 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        public static void TraceError(string Message)
        {
            Loger.Error(Message);
        }

        /// <summary>
        /// 写入 Error 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        /// <param name="args">variable argument list</param>
        public static void TraceError(string Message, params object[] args)
        {
            Loger.ErrorFormat(Message,args);
        }

        /// <summary>
        /// 写入 Error 级别的日志
        /// </summary>
        public static void TraceError(string additionalMessage, Exception ex)
        {
            Loger.Error(additionalMessage, ex);
        }

        /// <summary>
        /// 写入 Error 级别的日志
        /// </summary>
        public static void TraceError(Exception ex)
        {
            Loger.Error(string.Empty, ex);
        }


        /// <summary>
        /// 写入 Fatal 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        public static void TraceFatal(string Message)
        {
            Loger.Fatal(Message);
        }

        /// <summary>
        /// 写入 Fatal 级别的日志
        /// </summary>
        /// <param name="Message">The information write to the trace stream</param>
        /// <param name="args">variable argument list</param>
        public static void TraceFatal(string Message, params object[] args)
        {
            Loger.ErrorFormat(Message, args);
        }

        /// <summary>
        /// 写入 Fatal 级别的日志
        /// </summary>
        public static void TraceFatal(string additionalMessage, Exception ex)
        {
            Loger.Fatal(additionalMessage, ex);
        }

        /// <summary>
        /// 写入 Fatal 级别的日志
        /// </summary>
        public static void TraceFatal(Exception ex)
        {
            Loger.Fatal(string.Empty, ex);
        }
        
    }
}
